-
Notifications
You must be signed in to change notification settings - Fork 340
fix(build): stabilize rollup terser on Windows by limiting workers #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(build): stabilize rollup terser on Windows by limiting workers #1138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to stabilize Rollup production builds on Windows by reducing Terser parallelism, mitigating intermittent worker spawn failures and OOM conditions during minification (Fixes #1137).
Changes:
- Introduces a shared
TERSER_OPTIONSconstant withnumWorkers: 1in affected packages’ Rollup configs. - Updates production minification steps to call
terser(TERSER_OPTIONS)instead ofterser().
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/markups/rollup.config.js | Limits Terser worker count during production minification. |
| packages/react/rollup.config.js | Limits Terser worker count for both CJS and ESM production outputs. |
| packages/ui-elements/rollup.config.js | Limits Terser worker count during production minification. |
| packages/ui-kit/rollup.config.js | Limits Terser worker count during production minification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import dts from 'rollup-plugin-dts'; | ||
|
|
||
| const PRODUCTION = process.env.NODE_ENV === 'production'; | ||
| const TERSER_OPTIONS = { numWorkers: 1 }; |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.
| const TERSER_OPTIONS = { numWorkers: 1 }; | |
| const TERSER_NUM_WORKERS_ENV = process.env.TERSER_NUM_WORKERS; | |
| const TERSER_NUM_WORKERS = | |
| TERSER_NUM_WORKERS_ENV && !Number.isNaN(Number(TERSER_NUM_WORKERS_ENV)) | |
| ? Number(TERSER_NUM_WORKERS_ENV) | |
| : process.platform === 'win32' | |
| ? 1 | |
| : undefined; | |
| const TERSER_OPTIONS = TERSER_NUM_WORKERS | |
| ? { numWorkers: TERSER_NUM_WORKERS } | |
| : {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I kept this unconditional intentionally to prioritize build stability and keep the change minimal.
Happy to make it platform-specific or configurable if that’s preferred by maintainers.
| import dts from 'rollup-plugin-dts'; | ||
|
|
||
| const PRODUCTION = process.env.NODE_ENV === 'production'; | ||
| const TERSER_OPTIONS = { numWorkers: 1 }; |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.
| const TERSER_OPTIONS = { numWorkers: 1 }; | |
| const TERSER_OPTIONS = | |
| process.platform === 'win32' ? { numWorkers: 1 } : {}; |
|
|
||
| const packageJson = require('./package.json'); | ||
| const PRODUCTION = process.env.NODE_ENV === 'production'; | ||
| const TERSER_OPTIONS = { numWorkers: 1 }; |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.
| const TERSER_OPTIONS = { numWorkers: 1 }; | |
| const TERSER_NUM_WORKERS = process.env.TERSER_NUM_WORKERS; | |
| const TERSER_OPTIONS = | |
| TERSER_NUM_WORKERS != null && TERSER_NUM_WORKERS !== '' | |
| ? { numWorkers: Number(TERSER_NUM_WORKERS) } | |
| : process.platform === 'win32' | |
| ? { numWorkers: 1 } | |
| : {}; |
| import dts from 'rollup-plugin-dts'; | ||
|
|
||
| const PRODUCTION = process.env.NODE_ENV === 'production'; | ||
| const TERSER_OPTIONS = { numWorkers: 1 }; |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: numWorkers: 1 is applied unconditionally, which may slow down production builds on non-Windows platforms too. If the instability is Windows-specific, consider making this conditional (e.g., only on process.platform === 'win32') or configurable via an environment variable so CI/macOS/Linux can keep parallel minification.
| const TERSER_OPTIONS = { numWorkers: 1 }; | |
| const TERSER_NUM_WORKERS = | |
| process.env.TERSER_NUM_WORKERS && | |
| parseInt(process.env.TERSER_NUM_WORKERS, 10); | |
| const TERSER_OPTIONS = | |
| Number.isInteger(TERSER_NUM_WORKERS) && TERSER_NUM_WORKERS > 0 | |
| ? { numWorkers: TERSER_NUM_WORKERS } | |
| : process.platform === 'win32' | |
| ? { numWorkers: 1 } | |
| : {}; |
Stabilizes Windows Rollup builds by limiting Terser worker parallelism to avoid OOM and worker spawn failures.
Windows Rollup Build Stability
Acceptance Criteria fulfillment
Call retries were exceeded,spawn UNKNOWN, OOM).numWorkers: 1) in affected packages.Fixes #1137
What changed
This PR limits terser worker parallelism to avoid Windows process/memory pressure:
packages/markups/rollup.config.jspackages/react/rollup.config.jspackages/ui-elements/rollup.config.jspackages/ui-kit/rollup.config.jsEach now uses:
const TERSER_OPTIONS = { numWorkers: 1 }terser(TERSER_OPTIONS)in build outputs.Why this is safe
This is a conservative build-time-only change.
It preserves deterministic output and does not change runtime behavior of the packages.
PR Test Details
Validated locally on Windows with Node
16.19.0/ Yarn3.6.4:yarn workspace @embeddedchat/markups build✅yarn workspace @embeddedchat/ui-elements build✅yarn workspace @embeddedchat/ui-kit build✅yarn workspace @embeddedchat/react build✅Notes:
yarn buildmay still fail in low-disk environments due to unrelatedENOSPC(disk space) errors.